package com.cskaoyan.controller.backStage;

import com.cskaoyan.model.Ad;
import com.cskaoyan.model.bo.SelectAdBO;
import com.cskaoyan.model.vo.AdDataVO;
import com.cskaoyan.model.vo.AdQueryAdInfoVO;
import com.cskaoyan.model.vo.BaseRespVO;
import com.cskaoyan.model.vo.ExceptionVO;
//import com.cskaoyan.model.vo.UserDataVO;
import com.cskaoyan.service.AdService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName: AdController
 * @Description: 广告管理
 * @Author:YPS
 * @Date: 2022/5/5 20:13
 * @Version: 1.0
 **/

@RestController
@RequestMapping("admin/ad")
public class AdController {

    //显示广告list

    @Autowired

    AdService adService;

    @RequiresPermissions("admin:ad:list")
    @RequestMapping("list")
    public BaseRespVO<AdDataVO> selectAd(SelectAdBO adBO){
        AdDataVO adDataVO = adService.queryAd(adBO);
        return BaseRespVO.ok(adDataVO);
    }
    //添加广告
    @RequiresPermissions("admin:ad:create")
    @RequestMapping("create")
    public BaseRespVO<AdQueryAdInfoVO> createAd(@RequestBody AdQueryAdInfoVO adQueryAdInfoVO ){
        AdQueryAdInfoVO selectAdBO = adService.insertAd(adQueryAdInfoVO);
        return BaseRespVO.ok(selectAdBO);
    }
    //编辑广告信息
    @RequiresPermissions("admin:ad:update")
    @RequestMapping("update")
    public BaseRespVO<AdQueryAdInfoVO> updateAd(@RequestBody AdQueryAdInfoVO adQueryAdInfoVO){
        AdQueryAdInfoVO updateAd = adService.updateAd(adQueryAdInfoVO);
        return BaseRespVO.ok(updateAd);
    }
    //删除广告信息
    @RequiresPermissions("admin:ad:delete")
    public ExceptionVO deleteAd(@RequestBody AdQueryAdInfoVO adQueryAdInfoVO){
        ExceptionVO exception = new ExceptionVO();
        adService.deleteAd(adQueryAdInfoVO);
        return exception;
    }
}
